package ua.kharkov.khpi.tarasenko.bach.dao.mysql;

import java.sql.Connection;

import org.apache.log4j.Logger;

import ua.kharkov.khpi.tarasenko.bach.core.db.EShopDataStoreException;
import ua.kharkov.khpi.tarasenko.bach.dao.core.DAOFactory;
import ua.kharkov.khpi.tarasenko.bach.dao.core.category.CategoryDAO;
import ua.kharkov.khpi.tarasenko.bach.dao.core.item.ItemDAO;
import ua.kharkov.khpi.tarasenko.bach.dao.core.order.OrderItemDAO;
import ua.kharkov.khpi.tarasenko.bach.dao.core.order.OrderUserDAO;
import ua.kharkov.khpi.tarasenko.bach.dao.core.user.UserDAO;
import ua.kharkov.khpi.tarasenko.bach.dao.mysql.category.MysqlCategoryDAO;
import ua.kharkov.khpi.tarasenko.bach.dao.mysql.item.MysqlItemDAO;
import ua.kharkov.khpi.tarasenko.bach.dao.mysql.order.MysqlOrderCustomerDAO;
import ua.kharkov.khpi.tarasenko.bach.dao.mysql.order.MysqlOrderItemDAO;
import ua.kharkov.khpi.tarasenko.bach.dao.mysql.user.MysqlCustomerDAO;

public class MysqlDAOFactory extends DAOFactory {
	private static final Logger log = Logger.getLogger(MysqlDAOFactory.class);

	@Override
	public UserDAO getUserDAO(Connection conn)
			throws EShopDataStoreException {
		if (log.isTraceEnabled()) {
			log.trace("Creating new MysqlUserDAO");
		}
		return new MysqlCustomerDAO(conn);
	}

	@Override
	public ItemDAO getItemDAO(Connection conn)
			throws EShopDataStoreException {
		if (log.isTraceEnabled()) {
			log.trace("Creating new MysqlItemDAO");
		}
		return new MysqlItemDAO(conn);
	}

	@Override
	public CategoryDAO getCategoryDAO(Connection conn)
			throws EShopDataStoreException {
		if (log.isTraceEnabled()) {
			log.trace("Creating new MysqlCategoryDAO");
		}
		return new MysqlCategoryDAO(conn);
	}

	@Override
	public OrderUserDAO getOrderUserDAO(Connection conn)
			throws EShopDataStoreException {
		if (log.isTraceEnabled()) {
			log.trace("Creating new MysqlOrderUserDAO");
		}
		return new MysqlOrderCustomerDAO(conn);
	}

	@Override
	public OrderItemDAO getOrderItemDAO(Connection conn)
			throws EShopDataStoreException {
		if (log.isTraceEnabled()) {
			log.trace("Creating new MysqlOrderItemDAO");
		}
		return new MysqlOrderItemDAO(conn);
	}

}
